<extend name="template/base_index" />

<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
    <script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/cosmo-skin.css" />
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <!-- 过滤\查询按钮 -->
            <div class="filter-controls">
                {:W('OrgArea/area')}
                <!-- 日期查询 -->
                <form action="{:U('Admin/Orders/deliverGoods')}" method="post" class="searchForm form-inline">




                </form>
            </div>
            <!-- 操作按钮 -->
            <div class="btn-controls row col-lg-12 col-md-12">
                <!--<a id="btnDeliver"  href="javascript:submitForm();" class="btn btn-primary"><i class="fa fa-bus"></i>发货</a>-->
                <!--<span class="help-block">［编辑发货信息］即发货操作！</span>-->
            </div>
            <form action="{:U('Admin/Orders/bulkDeliver')}" method="post" class="deliverForm" >
                <table class="table table-striped table table-hover  table-condensed">
                    <thead>
                    <tr>
                        <th>
                            <input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');" />
                        </th>
                        <th>
                            订单编号
                        </th>
                        <th>
                            下单用户
                        </th>
                        <th>
                            收货人
                        </th>
                        <th>
                            联系电话
                        </th>
                        <th>
                            总价格(元)
                        </th>
                        <th>
                            邮寄地址
                        </th>
                        <th>
                            订单状态
                        </th>
                        <th>
                            下单时间
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <empty name="people">
                        <tr>
                            <td colspan="10" class="text-center">{:L('NO_DATA')}</td>
                        </tr>
                        <else/>
                        <volist name="people" id="vo">
                            <tr>
                                <td>
                                    <input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem" />
                                </td>
                                <td>
                                    <a href="{:U('Admin/Orders/view',array('id'=>$vo['orderid']))}">{$vo.ordercode}</a>
                                </td>
                                <td>
                                    <a>{$vo.nickname}</a>
                                </td>
                                <td>
                                    {$vo.info.contactname}
                                </td>
                                <td>
                                    {$vo.info.mobile}
                                </td>
                                <td>
                                    {$vo['info']['price']+$vo['info']['post_price']}
                                </td>
                                <td>{$vo.info.province},{$vo.info.city},{$vo.info.area},{$vo.info.detailinfo}
                                </td>
                                <td>
                                    ({$vo.pay_type|getPayType})[{$vo.pay_status|getPayStatus}]
                                </td>
                                <td>
                                    {$vo.createtime|date='Y-m-d h:i:s',###}
                                </td>
                                <td>
                                    <a href="{:U('Admin/Orders/deliver',array('id'=>$vo['orderid']))}"
                                    <eq name="orderStatus" value="4">class="btn btn-warning btn-sm"><i class="fa fa-edit"></i>修改发货信息<else/>class="btn btn-primary  btn-sm"><i class="fa fa-edit"></i>编辑发货信息</eq>
                                    </a>
                                </td>
                            </tr>

                        </volist>
                    </empty>
                    </tbody>
                </table>
                <div>{$show}</div>
            </form>

            <script type="text/javascript">
                function submitForm(){
                    $(".submitForm").submit();
                }

                $(function() {

                });
            </script>
        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">

    <script src="__CDN__/select2/4.0.0/js/select2.min.js"></script>
    <script src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
    <script type="text/javascript">
        $(function(){
            $('a.num').each(function(){
                $(this).attr('href',$(this).attr('href')+"?orderStatus={$orderstatus}");
            })

            $('a.next').each(function(){
                $(this).attr('href',$(this).attr('href')+"?orderstatus={$orderstatus}");
            })

            $('a.prev').each(function(){
                $(this).attr('href',$(this).attr('href')+"?orderstatus={$orderstatus}");
            })






            $(".orderstatus").click(function(){
                $(".searchForm").submit();
            });
            $("#user_select2").select2({
                placeholder: "输入用户id或昵称查询"	,
                language: "zh-CN",
                ajax: {
                    url: "{:U('Admin/Member/select')}",
                    dataType: 'json',
                    delay: 250,
                    data: function (params) {
                        var queryParameters = {
                            q: params.term
                        }
                        return queryParameters;

                    },
                    processResults: function (data, page) {
                        if(!data.info){
                            data.info = new Array();
                            data.info['nodata']="无相关数据";
                        }
                        // parse the results into the format expected by Select2.
                        // since we are using custom formatting functions we do not need to
                        // alter the remote JSON data
                        return {
                            results: data.info
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                templateSelection: function (repo) {
                    return repo.nickname || repo.text;
                },
                templateResult: function (repo) {

                    if (repo.loading) return repo.text;
                    if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                    var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                    return $(markup);
                },
            });
        });
    </script>

</block>